package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.service.AlertDataService;
import com.zzyl.service.AlertRuleService;
import com.zzyl.vo.AlertDataVo;
import com.zzyl.vo.AlertRuleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sjqn
 */
@RestController
@RequestMapping("/alert-data")
@Api(tags = "管理端 - 报警规则相关接口")
public class AlertDataController {

    @Autowired
    private AlertDataService alertDataService;


    @GetMapping("/pageQuery")
    @ApiOperation(value = "分页获取告警数据列表", notes = "接收一个Pageable参数作为请求参数，返回一个包含分页数据的Page<AlertRuleDto>")
    public ResponseResult<PageResponse<AlertRuleVo>> getAlertRulePage(AlertDataPageQueryDto alertDataPageQueryDto) {
        PageResponse<AlertDataVo> alertDataVoPageResponse = alertDataService.adminPageQuery(alertDataPageQueryDto);
        return ResponseResult.success(alertDataVoPageResponse);
    }

    @PutMapping("/handleAlertData/{id}")
    @ApiOperation(value = "处理告警数据", notes = "接收一个id作为请求参数，返回一个包含分页数据的Page<AlertRuleDto>")
    public ResponseResult<AlertDataVo> handleAlertData(@PathVariable Long id, @RequestBody AlertDataHandleDto alertDataHandleDto) {
        alertDataService.handleAlertData(id, alertDataHandleDto);
        return ResponseResult.success();
    }


}
